package tests;

import static org.junit.Assert.*;

import java.io.File;
import java.util.Date;
import org.junit.Before;
import org.junit.Test;
import papers.Manuscript;
import users.Author;
/**
 * Tests the methods for adding and getting manuscripts in the author class
 * @author Taylor Zielske
 * @version 10.20.2011
 */
public class TestAuthor {
	private Author my_author;
	private Manuscript paper;
	/**
	 * Initializes the Author and Manuscript
	 */
	@Before
	public void setUp() {
		my_author = new Author("Taylor");
		paper = new Manuscript(my_author, new Date(), "Paper1",
				new File("Paper1.txt"));
	}
	/**
	 * Tests creating a new author with no manuscripts
	 */
	@Test
	public void testAuthorhasNoManuscripts() {
		assertEquals("New author has no manuscripts", 0, my_author
				.getManuscripts().size());
	}
	/**
	 * Tests adding a manuscript to the author class
	 */
	@Test
	public void testAddManuscript() {
		my_author.addManuscript(paper);
		assertEquals("Adding a manuscript adds to authors total manuscripts", 1,
				my_author.getManuscripts().size());
	}
	/**
	 * Test getting the manuscripts from the author class
	 */
	@Test
	public void testGetManuscript() {
		my_author.addManuscript(paper);
		assertTrue("Added manuscript is found in papers", my_author.getManuscripts()
				.contains(paper));
	}
	
	/**
	 * Test getting the role from the author class
	 */
	@Test
	public void testGetRole() {
		assertEquals("The role is not the same", "Author",
				my_author.getRole());
	}
}
